/*
 * Copyright 2007-2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cloudcompare.web.servlet.mvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.cloudcompare.diff.bean.Differences;
import com.cloudcompare.diff.bean.TreeNode;
import com.cloudcompare.diff.compare.Compare;
import com.cloudcompare.diff.utils.TreeUtils;

@Controller
public class CompareController {

	private static final String TREE_KEY = "tree";
    @Autowired
    private Compare comparer;

    /**
     * <p>Solicitud del formulario de comparacion.</p>
     * 
     * <p>Expected HTTP GET and request '/compare/new'.</p>
     */
    @RequestMapping(value="/compare/new", method=RequestMethod.GET)
    public void form() {}
    
    /**
     * <p>Saves a person.</p>
     * 
     * <p>Expected HTTP POST and request '/person/form'.</p>
     */
    @RequestMapping(value="/compare/process", method=RequestMethod.POST)
    public @ModelAttribute(TREE_KEY) TreeNode process() {
        System.out.println("Ejecutando process");
        String localObject1 = "C:\\comparar\\Pangea-0.0.1-SNAPSHOT.jar";
		String localObject2 = "C:\\comparar\\Pangea.jar";
        return TreeUtils.buildTree(comparer.compare(localObject1, localObject2));
    }

}
